﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Module.Core.BusinessLogic;
using Module.Core.Common;
using Module.Core.EntitiesInfo;
using Module.Core.LoginSystem.Commons.Framwork;

namespace Web.Cms.Member
{
    public partial class ChangesPassword : AdminPage
    {
        #region Khai báo
        private int idMember = 0;
        #endregion

       
       #region page_load
        protected void Page_Load(object sender, EventArgs e)
        {
            idMember = ObjConvertUtility.ToInt32(Request.QueryString["idMember"]);
            try
            {

                if (!Page.IsPostBack)
                {

                    LoadData();
                }
            }
            catch (Exception ex)
            {
            }

        }
      #endregion

        #region LoadData
        private void LoadData()
        {
            try
            {
                if (idMember > 0)
                {
                    buttonUpdate.Visible = true;
                    MemberInfo info = MemberBL.Select(idMember.ToString(), 2);
                    if (info != null)
                    {
                        txtEmail.Text = info.Email;
                      
                    }
                }
               
               
            }
            catch (Exception ex)
            {
                lblUpdateStatus.Text = "Error: " + ex.Message;
            }
        }
        #endregion

        #region FillData
        void FillData(MemberInfo info)
        {
            info.IdMember = idMember;
            info.Email = txtEmail.Text;
          

        }
        #endregion

      
        #region đổi mật khẩu
        protected void buttonUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                MemberInfo info = new MemberInfo();
                FillData(info);
                MemberBL.ChangesPass(txtEmail.Text, MyUtility.MySecurity.Encrypt_MD5(txtNewPassword.Text));
                lblUpdateStatus.Text = "Bạn đổi mật khẩu thành công";
            }
            catch (Exception ex)
            {
                lblUpdateStatus.Text = "Error: " + ex.Message;
            }
        }
        #endregion
    }
}